package seri;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;

import org.junit.Test;

/**
 * 序列化测试
 * 
 * @author Administrator
 * @date 2017年4月12日 
 * @copyright wonhigh.cn 
 */
public class SeriTest {
	
	@Test
	public void test1() throws Exception {
		File file = new File("D:\\test.txt");
		OutputStream oStream = new FileOutputStream(file);
		ObjectOutputStream os = new ObjectOutputStream(oStream);

		Student student = new Student("liu.r", 25, "man");
		
		os.writeObject(student);
		os.close();
		System.out.println(student);
	}
	
	@Test
	public void test2() throws Exception {
		File file = new File("D:\\test.txt");
		FileInputStream fis = new FileInputStream(file);
		ObjectInputStream ois = new ObjectInputStream(fis);
		
		Student readObject = (Student) ois.readObject();
		
		ois.close();
		System.out.println(readObject);
	} 
}
